<?php    
header('Content-type: application/xls');
header("Content-Disposition:attachment;filename=kenhnv.xls");

?>
<?php if (!empty($phankenhs)){?>
	 <table >
            <tr><td colspan="3" align="center" style="font-weight: bold; ">
<? echo $tendv ['Zdv'] ['tendvcha'];?>
            </td>
            <td colspan="3" align="center" style="font-weight: bold; ">CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM</td>
            </tr>
            <tr>
            <td colspan="3" align="center" style="font-weight: bold; ">
             <?php
echo $tendv['Zdv'] ['tendv'];
?>
            
             </td>
                <td colspan="3" align="center" style="font-weight: bold; ">Độc lập- tự do- hạnh phúc</td>
            </tr>
            <tr>
            <td colspan="6" align="center" style="font-weight: bold; font-size: large;">
          Danh sách các kênh <?php echo $tenloai['Loaikenh'] ['loaikenh']?> 
            </td>
            </tr>
             <tr>
            <td colspan="6" align="center" style="font-weight: bold; ">
          <?php echo '<strong>Nhân viên: '.$n ['Nhanvien']  ['manv'].'- '.
                $n ['Nhanvien'] ['tennv'].'</strong>';?>
            </td>
            </tr>
    </table>
	<table cellpadding="0" cellspacing="0" border="1">
	<tr>
			<th style="background: #d5d5d5; font-weight: bold"><?php echo 'STT';?></th>
			<th  style="background: #d5d5d5; font-weight: bold"><?php echo 'Mã Kênh';?></th>
			<th style="background: #d5d5d5; font-weight: bold"> <?php echo 'Kênh';?></th>
			<th  style="background: #d5d5d5; font-weight: bold"><?php echo 'Địa Chỉ';?></th>
			<th style="background: #d5d5d5; font-weight: bold"><?php echo 'Điện thoại';?></th>
            <th style="background: #d5d5d5; font-weight: bold"> <?php echo 'Ngày nhận';?></th>
	</tr>
	<?php
	$i = 0;
	foreach ($phankenhs as $phankenh):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
		<td><?php echo $i ?>&nbsp;</td>
		<td>
			<?php echo $phankenh['Kenh']['makenh']; ?>
		</td>
		<td>
			<?php echo $phankenh['Kenh']['tenkenh']; ?>
		</td>
		<td>
			<?php echo $phankenh['Kenh']['diachi'] ?>
		</td>
		<td>
			<?php echo $phankenh['Kenh']['sdt'] ?>
		</td>
		<td>
			<?php echo  date('d-m-Y',strtotime($phankenh['Phankenh']['ngaybd_hd']));  ?>
		</td>
	</tr>
<?php endforeach; ?>
	</table>

	<?php } else {echo "<h2>Nhân Viên Này Chưa Được Phân Kênh</h2>";} ?>